package com.edu.d8_tcp5;

import javax.sql.PooledConnection;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

/**
 * BS架构，使用线程池进行优化
 */
public class ServerReaderRunable implements Runnable{
    private Socket socket;
    public ServerReaderRunable(Socket socket) {
        this.socket=socket;
    }

    @Override
    public void run() {

        /**
         * 立即响应一个网页内容，给浏览器显示
         */
        try {
            OutputStream outputStream = socket.getOutputStream();

            PrintStream printStream = new PrintStream(outputStream);
            printStream.println("HTTP/1.1 200 OK");
            printStream.println("Content-Type:text/html;charset=UTF-8");
            printStream.println();//必须换行
            printStream.println("<div style='color:red;font-size:120px;text-align:center'>黑阿黑啊黑啊黑啊<div>");
            printStream.close();
            socket.close();
        } catch (IOException e) {

        }

    }
}
